<html>
<head><meta charset="utf-8"><title>GATs usage reports · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GATs.20usage.20reports.html">GATs usage reports</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="248403737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GATs%20usage%20reports/near/248403737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pl <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GATs.20usage.20reports.html#248403737">(Aug 04 2021 at 20:26)</a>:</h4>
<p>I've been using GATs a little bit. One use case is being able to abstract over lock implementations and their read/write guards. Something like</p>
<div class="codehilite"><pre><span></span><code>trait Lock&lt;T&gt; {
   type ReadGuard&lt;&#39;a&gt;: Deref&lt;Target=T&gt; where T: &#39;a;
}
</code></pre></div>



<a name="248403899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GATs%20usage%20reports/near/248403899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GATs.20usage.20reports.html#248403899">(Aug 04 2021 at 20:27)</a>:</h4>
<p>Ooh, neat</p>



<a name="248404124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GATs%20usage%20reports/near/248404124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GATs.20usage.20reports.html#248404124">(Aug 04 2021 at 20:29)</a>:</h4>
<p>Would you also have a <code>WriteGuard</code>?</p>



<a name="248404294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GATs%20usage%20reports/near/248404294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pl <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GATs.20usage.20reports.html#248404294">(Aug 04 2021 at 20:30)</a>:</h4>
<p>Yeah, it looks about the same just with DerefMut. For something like std's <code>Mutex</code> the implementation is the same.</p>
<p>It can cover all std's locks and crossbeams. I haven't played with any others</p>



<a name="248406487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GATs%20usage%20reports/near/248406487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GATs.20usage.20reports.html#248406487">(Aug 04 2021 at 20:43)</a>:</h4>
<p>Nice!</p>



<a name="248406538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/GATs%20usage%20reports/near/248406538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/GATs.20usage.20reports.html#248406538">(Aug 04 2021 at 20:44)</a>:</h4>
<p>Thanks for sharing :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>